import { Response } from "express"
import { SystemRepository } from "../repo/SystemRepository"
import { UserRepository } from "../repo/UserRepository"
import { UserListParam } from "@Tea/model"

export class SystemContext {
  private static inst: SystemContext
  private repo: SystemRepository = SystemRepository.getInstance()
  private userRepo: UserRepository = UserRepository.getInstance()

  // 单例
  public static getInstance() {
    if (!SystemContext.inst) {
      SystemContext.inst = new SystemContext()
    }

    return SystemContext.inst
  }

  getMune() {
    return this.repo.getMune()
  }

  getSystemInfo(res: Response) {
    return this.repo.getSystemInfo(res)
  }

  async getUserList() {
    const param: UserListParam = {
      username: "",
      enable:1,
      currentPage: 1,
      pageSize: 100000
    }
    return (await this.userRepo.getUserList(param, "admin"))[0]
  }

  getDeactivateUser() {
    return this.userRepo.getDeactivateUser()
  }
}